<html>
<head><meta charset="utf-8"><title>Marker Traits · project-safe-transmute · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/index.html">project-safe-transmute</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html">Marker Traits</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="190373635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/190373635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#190373635">(Mar 12 2020 at 10:14)</a>:</h4>
<p>I've created a repo for defining base marker traits that can be shared among all implementations of safe transmute. Again, the idea is that this repo would be the launching pad for any traits that would wind up in the std lib. Here is the first issue for discussing FromBytes/AsBytes <a href="https://github.com/rylev/mem-markers/issues/1" target="_blank" title="https://github.com/rylev/mem-markers/issues/1">https://github.com/rylev/mem-markers/issues/1</a> (note: this is on my personal GitHub until we can transfer to the rust-secure-code organization)</p>



<a name="190412189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/190412189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#190412189">(Mar 12 2020 at 16:37)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> <span class="user-mention" data-user-id="132362">@Joshua Liebow-Feeser</span> one thing I would love to talk more about is how useful these marker traits are or are not to Typic</p>



<a name="190416583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/190416583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#190416583">(Mar 12 2020 at 17:10)</a>:</h4>
<p>Thanks to <span class="user-mention" data-user-id="127617">@Shnatsel</span> the repo has been moved: <a href="https://github.com/rust-secure-code/mem-markers" target="_blank" title="https://github.com/rust-secure-code/mem-markers">https://github.com/rust-secure-code/mem-markers</a></p>



<a name="190417018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/190417018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Shnatsel <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#190417018">(Mar 12 2020 at 17:14)</a>:</h4>
<p>I've invited some people as admins to this repo but I'm sure I'm forgetting someone. If you want write access and did not receive an invite, ping me</p>



<a name="191230223"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/191230223" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#191230223">(Mar 20 2020 at 11:35)</a>:</h4>
<p>I'd like to start implementing some of the traits. Does anyone have any objections to this: <a href="https://github.com/rust-secure-code/mem-markers/issues/1" target="_blank" title="https://github.com/rust-secure-code/mem-markers/issues/1">https://github.com/rust-secure-code/mem-markers/issues/1</a>. I assume this crate also will support custom derives for each of them. Any objections to that?</p>



<a name="191230330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/191230330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#191230330">(Mar 20 2020 at 11:36)</a>:</h4>
<p><span class="user-mention" data-user-id="219211">@Jack Wrenn</span> <span class="user-mention" data-user-id="132362">@Joshua Liebow-Feeser</span> I'd also love to hear from you two since it's the least clear how well this plays into a typic style solution</p>



<a name="191273586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/191273586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Wrenn <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#191273586">(Mar 20 2020 at 17:15)</a>:</h4>
<p>I've left comments addressing your question on the github issue: <a href="https://github.com/rust-secure-code/mem-markers/issues/1#issuecomment-601810244" target="_blank" title="https://github.com/rust-secure-code/mem-markers/issues/1#issuecomment-601810244">https://github.com/rust-secure-code/mem-markers/issues/1#issuecomment-601810244</a></p>



<a name="191302891"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/191302891" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#191302891">(Mar 20 2020 at 21:09)</a>:</h4>
<p>I think that ToBytes and FromBytes are perhaps too broad and could be broken up into sub-markers and then you have ToBytes any time you have NoUninit and also FixedLayout</p>



<a name="191303082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/191303082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#191303082">(Mar 20 2020 at 21:11)</a>:</h4>
<p>But they should exist somewhere, so feel free to go ahead.</p>



<a name="194050327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194050327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194050327">(Apr 15 2020 at 15:42)</a>:</h4>
<p>Finally got to implementing some of the marker traits stuff. Here's a PR that implements FixedLayout (on any type that has a fixed layout): <a href="https://github.com/rust-secure-code/mem-markers/pull/7" title="https://github.com/rust-secure-code/mem-markers/pull/7">https://github.com/rust-secure-code/mem-markers/pull/7</a> It's not complete but puts the beginnings in place. I want to work on a NoUninit trait but I'm not sure how I'll do it. It's to tell if fields are NoUninit, but we'd need to have some idea of size of types to calculate if there is padding. Any ideas on this are welcome :-)</p>



<a name="194051273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194051273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194051273">(Apr 15 2020 at 15:49)</a>:</h4>
<p>It might be easier to do a <code>ByteComplete</code> trait which says that a type is valid no matter what bytes compromise it. I believe <code>FromBytes: FixedLayout + ByteComplete</code></p>



<a name="194310698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194310698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194310698">(Apr 16 2020 at 14:17)</a>:</h4>
<p>I unfortunately can't come up with a way to calculate type sizes at compile time and make compile decisions based on them. So I'm not sure how ToBytes can be done.</p>



<a name="194313389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194313389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194313389">(Apr 16 2020 at 14:35)</a>:</h4>
<p>I guess I will go with how zerocopy does it where they divide by zero in a const expression</p>



<a name="194323161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194323161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194323161">(Apr 16 2020 at 15:34)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> NoUninit means 99% of the time no padding. But are there any cases where it's interesting to know a type is NoUninit but is ?HasPadding?</p>



<a name="194323983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194323983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194323983">(Apr 16 2020 at 15:39)</a>:</h4>
<p>I don't think a type can even have padding bytes that are not uninit</p>



<a name="194325383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194325383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194325383">(Apr 16 2020 at 15:48)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> I mean a type can have uninit bytes that are not padding</p>



<a name="194325511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194325511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194325511">(Apr 16 2020 at 15:49)</a>:</h4>
<p>So there is a subtle distinction between a type with no padding and a type with no uninit bytes.</p>



<a name="194325688"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194325688" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194325688">(Apr 16 2020 at 15:50)</a>:</h4>
<p>oh, right</p>



<a name="194325712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194325712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194325712">(Apr 16 2020 at 15:50)</a>:</h4>
<p>yeah NoUninit is the stronger claim</p>



<a name="194325952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194325952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194325952">(Apr 16 2020 at 15:52)</a>:</h4>
<p>So the question is, should we make a distinction?</p>



<a name="194326099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194326099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194326099">(Apr 16 2020 at 15:52)</a>:</h4>
<p>Should there be a <code>NoPadding</code> trait and a <code>NoUninit: NoPadding</code> trait?</p>



<a name="194326244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194326244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194326244">(Apr 16 2020 at 15:53)</a>:</h4>
<p>MaybeUninit&lt;u8&gt; is NoPadding but it's not NoUninit</p>



<a name="194329229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194329229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194329229">(Apr 16 2020 at 16:12)</a>:</h4>
<p>I don't see the value in NoPadding on it own</p>



<a name="194329295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194329295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194329295">(Apr 16 2020 at 16:13)</a>:</h4>
<p>it doesn't let you do anything different</p>



<a name="194329351"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194329351" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194329351">(Apr 16 2020 at 16:13)</a>:</h4>
<p>The only thing I can see there is that you can be guranteed that it's packed. But I guess if you cared you would do <code>repr(packed)</code></p>



<a name="194329508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194329508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194329508">(Apr 16 2020 at 16:15)</a>:</h4>
<p>I'm trying to think of these as more than just traits for safe transmute. There will be other uses for such traits outside of straight transmute</p>



<a name="194357819"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194357819" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194357819">(Apr 16 2020 at 19:48)</a>:</h4>
<p>Sure, even outside of a transmuting context, I can't think of a single way to be able to do anything with a type once you know that it has no padding bytes, compared to what you could do before you knew that.</p>
<p>In other words, if you have <code>T: Foo + Bar</code> and then make it <code>T: Foo + Bar + NoPadding</code>, I can't imagine a single new thing that you'd be able to do just because of adding that extra bound of <code>NoPadding</code>.</p>



<a name="194373588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194373588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194373588">(Apr 16 2020 at 22:07)</a>:</h4>
<p>The only things I can think of are effectively tantamount to transmuting, yeah.</p>



<a name="194373635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194373635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194373635">(Apr 16 2020 at 22:07)</a>:</h4>
<p>I can't think of something you can do with a type if you know that it has no padding but has undefined values for some of its fields, or vice versa.</p>



<a name="194373648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194373648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194373648">(Apr 16 2020 at 22:07)</a>:</h4>
<p>Only things you can do if you know both that it has no padding <em>and</em> has no undefined values.</p>



<a name="194373694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194373694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194373694">(Apr 16 2020 at 22:08)</a>:</h4>
<p>Or things you can do if you know specifics of the types of its fields.</p>



<a name="194407296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194407296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194407296">(Apr 17 2020 at 08:10)</a>:</h4>
<p>It'd be great for people to check out the latest on master. We now have the beginnings of FixedLayout, NoUninit, ByteComplete, FromBytes and ToBytes. In particular do we think that these traits capture their invariants properly? Are there other invariants that are subtly being captured that would better be moved into another trait. Obviously invariants about size and alignment are not captured, but I believe everything else for a safe transmute is there (though of course a transmute that relies on these traits plus size and alignment invariants is naturally conservative).</p>



<a name="194407735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194407735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194407735">(Apr 17 2020 at 08:15)</a>:</h4>
<p>I'm not sure we're ready to answer this: but I'm constantly wondering if these traits would be useful in std. <span class="user-mention" data-user-id="219211">@Jack Wrenn</span> and <span class="user-mention" data-user-id="132362">@Joshua Liebow-Feeser</span> are going down the route of capturing layout in the type system so we can make adhoc judgement of whether two types are safely transmutable. This a great and super powerful/flexible way to address transmute. The mem markers in the mem-markers repo are a bit less fine grained and thus a bit less powerful in what they can do then Typic, but perhaps they provide guarantees around invariants that are also interesting outside of transmute and would thus be useful. Anyway, I'd like to start capturing usecases outside of transmute that these traits would be useful for.</p>



<a name="194408082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194408082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194408082">(Apr 17 2020 at 08:18)</a>:</h4>
<p>For example, while it's not complete knowing a type is FixedLayout is useful for ensuring safe FFI. A type must be fixed layout for it to be safe to marshal across FFI boundaries.</p>



<a name="194411942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194411942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194411942">(Apr 17 2020 at 08:57)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> Can I get your (or anyone else's) thoughts on the question of the usefulness of <code>ByteComplete</code> as distinguished from <code>FromBytes</code>: <a href="https://github.com/rust-secure-code/mem-markers/issues/14" title="https://github.com/rust-secure-code/mem-markers/issues/14">https://github.com/rust-secure-code/mem-markers/issues/14</a></p>



<a name="194414915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/216762-project-safe-transmute/topic/Marker%20Traits/near/194414915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rylev <a href="https://rust-lang.github.io/zulip_archive/stream/216762-project-safe-transmute/topic/Marker.20Traits.html#194414915">(Apr 17 2020 at 09:26)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> <span class="user-mention" data-user-id="224471">@Lokathor</span> trying my hardest to think of cases where it's useful to know that a type is NoPadding . I have one though it's a bit of a stretch. Say you need to allocate a buffer of memory to fit a type and you happen to know the sum of the sizes of the fields of that type, you can know that allocating size_of_fields bytes is enough space for the parent type as a whole because it has no padding. So there's no reason for an extra call to size_of. But seeing as how size of is a const function, I guess this doesn't matter.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>